# 请写出一段 Python 代码，使用列表推导式实现删除一个 list 里面的重复元素list1 = [1,2,3,5,2,1,5,7,9]。


list1 = [1,2,3,5,2,1,5,7,9]
list2 = []
# for i in list1:
#     if not i in list2:
#         list2.append(i)
#
# print(list2)

[list2.append(i)  for i in list1 if not i in list2]
print(list2)





class Singleton:
    __instant=None #创建一个类属性保存对象
    __has_init=None #判断是否初始化

    def __new__(cls, *args, **kwargs):
        #做判断,如果创建对象后分配过地址
        if cls.__instant is None:
            cls.__instant = super().__new__(cls) #创建一个对象并且分配地址
        return cls.__instant

#注意要实用类属性保存对象,要用类属性做判断 ,类属性的值变化了,方法才会发生变化



    def __init__(self):
        #如果已经初始化 就直接返回
        if Singleton.__has_init:
            return
        #如果没有初始化就初始化
        print('111111')
        #初始化过后再将标记修改成TRUE 不然下次进来还是没有初始化过
        Singleton.__has_init=True

s1 = Singleton()
print(s1)
s2 =Singleton()
print(s2)





# import random
# class Game:
#     top_score=0
#     @staticmethod
#     def show_help():
#         print('游戏帮助信息')
#     @classmethod
#     def show_top_score(cls):
#         return cls.top_score
#
#     def __init__(self,player_name):
#         self.player_name = player_name
#
#     def start_game(self):
#         get_Score=random.randint(10,100)
#         print(f'{self.player_name}得分{get_Score}')
#         if get_Score > self.top_score:
#             Game.top_score=get_Score
#
#
# print(Game.show_top_score())
# zhangsan = Game('张三')
# zhangsan.start_game()
# print(Game.show_top_score())
# zhangsan.start_game()
# print(Game.show_top_score())
#





